<?xml version='1.0' encoding='UTF-8' ?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	template="/pages/templates/template.xhtml">
	<ui:define name="metadata">
	</ui:define>
	<ui:define name="content">
		<h:form id="formListaConvites">
			<div>
				<div class="div-titulo-tela">
					<p:outputLabel styleClass="titulo-tela">Convites Enviados</p:outputLabel>
					<br /> <br />
					<p:separator></p:separator>
					<div class="div-titulo-botoes">
						<p:commandButton value="Novo" action="convite_novo.xhtml"></p:commandButton>
					</div>
				</div>
				<div>
					<div class="div-corpo-tela">
						<div class="div-mensagem">
							<p:messages id="messages" autoUpdate="true" closable="true" />
						</div>
						<p:dataTable id="dataTable" var="convite"
							emptyMessage="Nenhum convite realizado."
							value="#{ConviteListaBean.convitesEnviados}">
							
							<p:column headerText="Convidado">
								<h:outputText value="#{convite.convidado.matricula} - #{convite.convidado.nome} " />
							</p:column>

							<p:column headerText="Data">
								<h:outputText value="#{convite.dthConvite}" >
									<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="GMT-03:00" />
								</h:outputText>
							</p:column>

							<p:column headerText="Situação">
								<h:outputText value="#{convite.situacaoDesc}" />
							</p:column>
							
							<p:column style="width:4%">
									<p:commandButton id="btnRnviaMail" icon="ui-icon-mail-closed"  disabled="#{convite.situacao != 1}"
										title="Enviar E-mail" actionListener="#{ConviteListaBean.enviarAlerta(convite)}">
									</p:commandButton>
									<p:commandButton id="btnCancelar" icon="ui-icon-close"  disabled="#{convite.situacao != 1}"
										title="Cancelar" update="dataTable" onclick="confirmation.show()">
										<f:setPropertyActionListener
											target="#{ConviteListaBean.conviteRemove}" value="#{convite}"></f:setPropertyActionListener>
									</p:commandButton>
								</p:column>
						</p:dataTable>
					</div>
				</div>
			</div>
		</h:form>
		
		<p:confirmDialog id="confirmDialog"
			message="Realmente deseja cancelar este convite?"
			header="Convite" severity="alert" appendToBody="true"
			widgetVar="confirmation">
			<h:form id="formConfirm">
				<p:commandButton id="confirm" value="Sim"
					update=":formListaConvites:dataTable" oncomplete="confirmation.hide()"
					actionListener="#{ConviteListaBean.cancelaConvite}" />
				<p:commandButton id="decline" value="Não"
					onclick="confirmation.hide()" type="button" />
			</h:form>
		</p:confirmDialog>
		
	</ui:define>
</ui:composition>

